package com.hoopchina.ui.main;


import com.hoopchina.news.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

/**
 * Splash
 * 应用禁用时动画
 * 
 * @author Neusoft
 */
public class Splash extends UIWidget {
	private TextView                    mTxtSplash;        // information text
	private TextView                    mTxtUpdate;
	private Animation                   mAnimation;        // animation instance, now is pulling up in 2 seconds

	//构造器
	public Splash(Context context) {
		super(context);
	}

	//构造器
	public Splash(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	//加载资源
	@Override
	protected void loadResources() {
		LayoutInflater inflater = 
			( LayoutInflater )getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
		inflater.inflate( R.layout.splash, this, true );
		mTxtSplash = ( TextView )findViewById( R.id.txtSplash );
		mTxtUpdate = ( TextView )findViewById( R.id.txtSplashUpdate );
		System.out.println(">>>>>>>>>>>>>>loadResources<<<<<<<<<<<<<");
	}
	
	/**
	 * Set information text
	 * @param aText text string
	 */
	public void setText( String aText ) {
		mTxtSplash.setText( aText );
	}
	
	public void setUpdateText( String aText ) {
		mTxtUpdate.setText( aText );
	}


	/*
	 * 实现两秒开机动画
	 */
	public void startClosing() {
		mAnimation = AnimationUtils.loadAnimation( getContext(), R.anim.anim_splash );
		mAnimation.setAnimationListener( new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation animation) {
				notifyEvent( null );
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
				// no implementation
			}

			@Override
			public void onAnimationStart(Animation animation) {
				// no implementation
			}
		});
		this.startAnimation( mAnimation );
	}
}
